<?php
/**
 * 商品基本信息模块控制器
 * 
 */
class goodsAction extends apiAction {
	
	/**
	 * 获得品牌列表
	 */
	public function brands(){
		$data = array();
		$brands = D('brand')->cache(true, 600)->select();
		if($brands){
			foreach ($brands as $row){
				$data[] = array('brandId'=>$row['id'], 'brandName'=>$row['name']);
			}
		}
		$this->ajaxReturn(200, L('success'), $data);
	}

	/**
	 * 根据品牌 id获得机型列表
	 */
	public function models(){
		$brandId = I('brandId', NULL);
		
		$brand = D('brand')->cache(true, 600)->where(array('id'=>$brandId))->find();
		$models = D('model')->cache(true, 600)->where(array('status'=>1,'brandId'=>$brandId))->select();
		
		$data['brandId'] = $brand['id'];
		$data['brandName'] = $brand['name'];
			
		if($models){
			foreach ($models as $row){
				$data['models'][] = array('modelId'=>$row['id'], 'modelName'=>$row['name']);
			}
		}
		$this->ajaxReturn(200, L('success'), $data);
	}
	
}

/* End of file goodsAction.class.php */